/************** init.html **************/
function queryClassRoom(page) {
	var parm = $('#queryClassRoomForm').serialize() + sys_get_page(page);
	var url = create_url('classRoom-query');
	sys_query_parm = parm;
	sys_loading();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#classRoomResultList').html(result);
		}
	});
}

//屏蔽
function shieldClassRoom(code, name) {
	$.Zebra_Dialog('确认要屏蔽教室 ' + name + ' 吗？',{
		'type': 'question','title': '警告' ,'buttons':[
		  {caption:'屏蔽',callback:function() {
			  var url = create_url('classRoom-shield');
			  aidExecuteClassRoom(code, url);
		  }},
		{caption:'取消',callback:function(){}
		}]
	});
}

function unshieldClassRoom(code, name) {
	$.Zebra_Dialog('确认要解除教室 ' + name + '的屏蔽状态吗？',{
	'type': 'question','title': '警告' ,'buttons':[
       {caption:'解除',callback:function() {
    	   var url = create_url('classRoom-unshield');
    	   aidExecuteClassRoom(code, url);
		}},
    {caption:'取消',callback:function(){}
	}]
	});
}
function aidExecuteClassRoom(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				sys_msg('操作成功');
				queryClassRoom();
			} else {
				sys_warning('操作失败', '操作失败，请刷新页面再次尝试，如果问题依然存在，请联系管理员!');
			}
		}
	});
}

//跳转到新增数据页
function addClassRoom(){
	var url = create_url('classRoom-addEdit');
	$.colorbox({overlayClose:false, href:url, data:null, close:'[关闭]', width:'410px', height:'280px', open:true});

}

//新增教室
function saveAddEditClassRoom(){
	var parm = $('#addEditClassRoomForm').serialize();
	var url = create_url('classRoom-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if (result == 'success') {
				sys_msg('操作成功');
				sys_load_handle('classRoom');
				$.fn.colorbox.close();
			} else {
				sys_msg('操作失败，请刷新后重试');
			}
		}
	});
}